<?php

namespace common\validate;

class User extends BaseValidate
{
    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('phone', 'require|mobile')
            ->append('name', 'require|max:128')
            ->append('union_id', 'require')
            ->append('email', 'email');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('id', 'require')
            ->append('phone', 'mobile')
            ->append('name', 'max:128')
            ->append('email', 'email');
    }

    // GetUserListByRole 验证场景定义
    public function sceneGetUserListByRole()
    {
        return $this->append('param.filter.role_code', 'require');
    }

    // 创建用户资格证分类
    public function sceneCreateCertCategory()
    {
        return $this->append('data.name', 'require|max:255');
    }

    // 修改用户资格证分类
    public function sceneModifyCertCategory()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'require|max:255');
    }

    // 删除用户资格证分类
    public function sceneDeleteCertCategory()
    {
        return $this->append('param.filter', 'require');
    }

    // 创建用户资格证
    public function sceneCreateUserCert()
    {
        return $this->append('data.user_cert_category_id', 'require')
            ->append('data.base_man_hour', 'require|max:36')
            ->append('data.level', 'require')
            ->append('data.level_category', 'require|in:s,a,b,c')
            ->append('data.attribute_ids', 'require|array');
    }

    // 更新用户资格证
    public function sceneModifyUserCert()
    {
        return $this
            ->append('data.id', 'require')
            ->append('data.base_man_hour', 'max:36')
            ->append('data.level_category', 'in:s,a,b,c')
            ->append('data.attribute_ids', 'array');
    }

    // 删除更新用户资格证
    public function sceneDeleteUserCert()
    {
        return $this->append('param.filter', 'require');
    }

    // 获取用户资格证
    public function sceneSelectUserCert()
    {
        return $this->append('param.filter', 'require');
    }

    // SetUserCert 验证场景定义
    public function sceneSetUserCert()
    {
        return $this->append("data", "require")
            ->append("data.user_id", "require")
            ->append("data.user_cert_id", "require");
    }

    // GetUserList 验证场景定义
    public function sceneGetUserList()
    {
        return $this->append('param.filter', 'require');
    }
}
